<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE BangPatterns, CPP, NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Event.Array</span><span>
</span><span id="line-5"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-6"></span><span>      </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier">Array</span></a></span><span>
</span><span id="line-7"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#capacity"><span class="hs-identifier">capacity</span></a></span><span>
</span><span id="line-8"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#clear"><span class="hs-identifier">clear</span></a></span><span>
</span><span id="line-9"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#concat"><span class="hs-identifier">concat</span></a></span><span>
</span><span id="line-10"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#copy"><span class="hs-identifier">copy</span></a></span><span>
</span><span id="line-11"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#duplicate"><span class="hs-identifier">duplicate</span></a></span><span>
</span><span id="line-12"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#empty"><span class="hs-identifier">empty</span></a></span><span>
</span><span id="line-13"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#ensureCapacity"><span class="hs-identifier">ensureCapacity</span></a></span><span>
</span><span id="line-14"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#findIndex"><span class="hs-identifier">findIndex</span></a></span><span>
</span><span id="line-15"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#forM_"><span class="hs-identifier">forM_</span></a></span><span>
</span><span id="line-16"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#length"><span class="hs-identifier">length</span></a></span><span>
</span><span id="line-17"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#loop"><span class="hs-identifier">loop</span></a></span><span>
</span><span id="line-18"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#new"><span class="hs-identifier">new</span></a></span><span>
</span><span id="line-19"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#removeAt"><span class="hs-identifier">removeAt</span></a></span><span>
</span><span id="line-20"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#snoc"><span class="hs-identifier">snoc</span></a></span><span>
</span><span id="line-21"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#unsafeLoad"><span class="hs-identifier">unsafeLoad</span></a></span><span>
</span><span id="line-22"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#unsafeCopyFromBuffer"><span class="hs-identifier">unsafeCopyFromBuffer</span></a></span><span>
</span><span id="line-23"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#unsafeRead"><span class="hs-identifier">unsafeRead</span></a></span><span>
</span><span id="line-24"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#unsafeWrite"><span class="hs-identifier">unsafeWrite</span></a></span><span>
</span><span id="line-25"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#useAsPtr"><span class="hs-identifier">useAsPtr</span></a></span><span>
</span><span id="line-26"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Bits.html"><span class="hs-identifier">Data.Bits</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Bits.html#.%7C."><span class="hs-operator">(.|.)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Bits.html#shiftR"><span class="hs-identifier">shiftR</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.IORef.html"><span class="hs-identifier">Data.IORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IORef.html#IORef"><span class="hs-identifier">IORef</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IORef.html#atomicModifyIORef%27"><span class="hs-identifier">atomicModifyIORef'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IORef.html#newIORef"><span class="hs-identifier">newIORef</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IORef.html#readIORef"><span class="hs-identifier">readIORef</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier">writeIORef</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Maybe.html"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.Types.html"><span class="hs-identifier">Foreign.C.Types</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier">CSize</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.ForeignPtr.html"><span class="hs-identifier">Foreign.ForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier">ForeignPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier">withForeignPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Ptr.html"><span class="hs-identifier">Foreign.Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier">nullPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#plusPtr"><span class="hs-identifier">plusPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Storable.html"><span class="hs-identifier">Foreign.Storable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier">Storable</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Base.html#empty"><span class="hs-identifier">empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html"><span class="hs-identifier">GHC.ForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#mallocPlainForeignPtrBytes"><span class="hs-identifier">mallocPlainForeignPtrBytes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#newForeignPtr_"><span class="hs-identifier">newForeignPtr_</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier">unsafeWithForeignPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Num.html"><span class="hs-identifier">GHC.Num</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Num.html#Num"><span class="hs-identifier">Num</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Real.html"><span class="hs-identifier">GHC.Real</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier">fromIntegral</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Show.html"><span class="hs-identifier">GHC.Show</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Show.html#show"><span class="hs-identifier">show</span></a></span><span class="hs-special">)</span><span class="hs-cpp">

#include &quot;MachDeps.h&quot;
</span><span class="hs-cpp">
#define BOUNDS_CHECKING 1
</span><span class="hs-cpp">
#if defined(BOUNDS_CHECKING)
</span><span class="hs-comment">-- This fugly hack is brought by GHC's apparent reluctance to deal</span><span>
</span><span id="line-47"></span><span class="hs-comment">-- with MagicHash and UnboxedTuples when inferring types. Eek!</span><span class="hs-cpp">
#define CHECK_BOUNDS(_func_,_len_,_k_) \
if (_k_) &lt; 0 || (_k_) &gt;= (_len_) then errorWithoutStackTrace (&quot;GHC.Event.Array.&quot; ++ (_func_) ++ &quot;: bounds error, index &quot; ++ show (_k_) ++ &quot;, capacity &quot; ++ show (_len_)) else
</span><span class="hs-cpp">#else
</span><span class="hs-cpp">#define CHECK_BOUNDS(_func_,_len_,_k_)
</span><span class="hs-cpp">#endif
</span><span>
</span><span id="line-54"></span><span class="hs-comment">-- Invariant: size &lt;= capacity</span><span>
</span><span id="line-55"></span><span class="hs-keyword">newtype</span><span> </span><span id="Array"><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-var">Array</span></a></span></span><span> </span><span id="local-6989586621679550702"><span class="annot"><a href="#local-6989586621679550702"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="Array"><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-var">Array</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IORef.html#IORef"><span class="hs-identifier hs-type">IORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550702"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span class="hs-comment">-- The actual array content.</span><span>
</span><span id="line-58"></span><span class="hs-keyword">data</span><span> </span><span id="AC"><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span></span><span> </span><span id="local-6989586621679550697"><span class="annot"><a href="#local-6989586621679550697"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="AC"><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span></span><span>
</span><span id="line-59"></span><span>    </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550697"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Elements</span><span>
</span><span id="line-60"></span><span>    </span><span class="hs-glyph">!</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>      </span><span class="hs-comment">-- Number of elements (length)</span><span>
</span><span id="line-61"></span><span>    </span><span class="hs-glyph">!</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>      </span><span class="hs-comment">-- Maximum number of elements (capacity)</span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span id="local-6989586621679550710"><span class="annot"><a href="GHC.Event.Array.html#empty"><span class="hs-identifier hs-type">empty</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550710"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-64"></span><span id="empty"><span class="annot"><span class="annottext">empty :: forall a. IO (Array a)
</span><a href="GHC.Event.Array.html#empty"><span class="hs-identifier hs-var hs-var">empty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-65"></span><span>  </span><span id="local-6989586621679550543"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550543"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; IO (ForeignPtr a)
forall a. Ptr a -&gt; IO (ForeignPtr a)
</span><a href="GHC.ForeignPtr.html#newForeignPtr_"><span class="hs-identifier hs-var">newForeignPtr_</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-66"></span><span>  </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; Array a
forall a. IORef (AC a) -&gt; Array a
</span><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-var">Array</span></a></span><span> </span><span class="annot"><span class="annottext">(IORef (AC a) -&gt; Array a) -&gt; IO (IORef (AC a)) -&gt; IO (Array a)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="GHC.Base.html#fmap"><span class="hs-operator hs-var">`fmap`</span></a></span><span> </span><span class="annot"><span class="annottext">AC a -&gt; IO (IORef (AC a))
forall a. a -&gt; IO (IORef a)
</span><a href="GHC.IORef.html#newIORef"><span class="hs-identifier hs-var">newIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
forall a. ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
</span><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550543"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span id="local-6989586621679550696"><span class="annot"><a href="GHC.Event.Array.html#allocArray"><span class="hs-identifier hs-type">allocArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550696"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550696"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-69"></span><span id="allocArray"><span class="annot"><span class="annottext">allocArray :: forall a. Storable a =&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="GHC.Event.Array.html#allocArray"><span class="hs-identifier hs-var hs-var">allocArray</span></a></span></span><span> </span><span id="local-6989586621679550537"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550537"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; IO (ForeignPtr a)
forall a. Storable a =&gt; a -&gt; IO (ForeignPtr a)
</span><a href="#local-6989586621679550536"><span class="hs-identifier hs-var">allocHack</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-70"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-71"></span><span>  </span><span id="local-6989586621679550692"><span class="annot"><a href="#local-6989586621679550536"><span class="hs-identifier hs-type">allocHack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550692"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550692"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550692"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-72"></span><span>  </span><span id="local-6989586621679550536"><span class="annot"><span class="annottext">allocHack :: forall a. Storable a =&gt; a -&gt; IO (ForeignPtr a)
</span><a href="#local-6989586621679550536"><span class="hs-identifier hs-var hs-var">allocHack</span></a></span></span><span> </span><span id="local-6989586621679550531"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550531"><span class="hs-identifier hs-var">dummy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr a)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="GHC.ForeignPtr.html#mallocPlainForeignPtrBytes"><span class="hs-identifier hs-var">mallocPlainForeignPtrBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550537"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550531"><span class="hs-identifier hs-var">dummy</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span id="local-6989586621679550685"><span class="annot"><a href="GHC.Event.Array.html#reallocArray"><span class="hs-identifier hs-type">reallocArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550685"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550685"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550685"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-75"></span><span id="reallocArray"><span class="annot"><span class="annottext">reallocArray :: forall a.
Storable a =&gt;
ForeignPtr a -&gt; Int -&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="GHC.Event.Array.html#reallocArray"><span class="hs-identifier hs-var hs-var">reallocArray</span></a></span></span><span> </span><span id="local-6989586621679550523"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550523"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679550522"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550522"><span class="hs-identifier hs-var">newSize</span></a></span></span><span> </span><span id="local-6989586621679550521"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550521"><span class="hs-identifier hs-var">oldSize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; ForeignPtr a -&gt; IO (ForeignPtr a)
forall a. Storable a =&gt; a -&gt; ForeignPtr a -&gt; IO (ForeignPtr a)
</span><a href="#local-6989586621679550520"><span class="hs-identifier hs-var">reallocHack</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550523"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-76"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-77"></span><span>  </span><span id="local-6989586621679550683"><span class="annot"><a href="#local-6989586621679550520"><span class="hs-identifier hs-type">reallocHack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550683"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550683"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550683"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550683"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-78"></span><span>  </span><span id="local-6989586621679550520"><span class="annot"><span class="annottext">reallocHack :: forall a. Storable a =&gt; a -&gt; ForeignPtr a -&gt; IO (ForeignPtr a)
</span><a href="#local-6989586621679550520"><span class="hs-identifier hs-var hs-var">reallocHack</span></a></span></span><span> </span><span id="local-6989586621679550500"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550500"><span class="hs-identifier hs-var">dummy</span></a></span></span><span> </span><span id="local-6989586621679550499"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550499"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-79"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550497"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621679550497"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550500"><span class="hs-identifier hs-var">dummy</span></a></span><span>
</span><span id="line-80"></span><span>      </span><span id="local-6989586621679550496"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550496"><span class="hs-identifier hs-var">dst</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr a)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="GHC.ForeignPtr.html#mallocPlainForeignPtrBytes"><span class="hs-identifier hs-var">mallocPlainForeignPtrBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550522"><span class="hs-identifier hs-var">newSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550497"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-81"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; (Ptr a -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550499"><span class="hs-identifier hs-var">src</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr a -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr a -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550495"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550495"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-82"></span><span>        </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550495"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Ptr a -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550521"><span class="hs-identifier hs-var">oldSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ())
-&gt; ((Ptr a -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr a -&gt; IO ()) -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-83"></span><span>          </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; (Ptr a -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550496"><span class="hs-identifier hs-var">dst</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr a -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr a -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550489"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550489"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-84"></span><span>            </span><span class="annot"><span class="annottext">Ptr a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Ptr a -&gt; CSize -&gt; IO (Ptr a)
forall a. Ptr a -&gt; Ptr a -&gt; CSize -&gt; IO (Ptr a)
</span><a href="GHC.Event.Array.html#memcpy"><span class="hs-identifier hs-var">memcpy</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550489"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550495"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550521"><span class="hs-identifier hs-var">oldSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550497"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span>            </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; IO (ForeignPtr a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550496"><span class="hs-identifier hs-var">dst</span></a></span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span id="local-6989586621679550663"><span class="annot"><a href="GHC.Event.Array.html#new"><span class="hs-identifier hs-type">new</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550663"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550663"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-89"></span><span id="new"><span class="annot"><span class="annottext">new :: forall a. Storable a =&gt; Int -&gt; IO (Array a)
</span><a href="GHC.Event.Array.html#new"><span class="hs-identifier hs-var hs-var">new</span></a></span></span><span> </span><span id="local-6989586621679550483"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550483"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-90"></span><span>    </span><span id="local-6989586621679550482"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550482"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr a)
forall a. Storable a =&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="GHC.Event.Array.html#allocArray"><span class="hs-identifier hs-var">allocArray</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550481"><span class="hs-identifier hs-var">cap</span></a></span><span>
</span><span id="line-91"></span><span>    </span><span class="annot"><span class="annottext">(IORef (AC a) -&gt; Array a) -&gt; IO (IORef (AC a)) -&gt; IO (Array a)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; Array a
forall a. IORef (AC a) -&gt; Array a
</span><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-var">Array</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AC a -&gt; IO (IORef (AC a))
forall a. a -&gt; IO (IORef a)
</span><a href="GHC.IORef.html#newIORef"><span class="hs-identifier hs-var">newIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
forall a. ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
</span><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550482"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550481"><span class="hs-identifier hs-var">cap</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-92"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-93"></span><span>    </span><span id="local-6989586621679550481"><span class="annot"><span class="annottext">cap :: Int
</span><a href="#local-6989586621679550481"><span class="hs-identifier hs-var hs-var">cap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int
</span><a href="GHC.Event.Array.html#firstPowerOf2"><span class="hs-identifier hs-var">firstPowerOf2</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550483"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span id="local-6989586621679550661"><span class="annot"><a href="GHC.Event.Array.html#duplicate"><span class="hs-identifier hs-type">duplicate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550661"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550661"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550661"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-96"></span><span id="duplicate"><span class="annot"><span class="annottext">duplicate :: forall a. Storable a =&gt; Array a -&gt; IO (Array a)
</span><a href="GHC.Event.Array.html#duplicate"><span class="hs-identifier hs-var hs-var">duplicate</span></a></span></span><span> </span><span id="local-6989586621679550475"><span class="annot"><span class="annottext">Array a
</span><a href="#local-6989586621679550475"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; Array a -&gt; IO (Array a)
forall b. Storable b =&gt; b -&gt; Array b -&gt; IO (Array b)
</span><a href="#local-6989586621679550474"><span class="hs-identifier hs-var">dupHack</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="annot"><span class="annottext">Array a
</span><a href="#local-6989586621679550475"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-97"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-98"></span><span>  </span><span id="local-6989586621679550659"><span class="annot"><a href="#local-6989586621679550474"><span class="hs-identifier hs-type">dupHack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550659"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550659"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550659"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550659"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-99"></span><span>  </span><span id="local-6989586621679550474"><span class="annot"><span class="annottext">dupHack :: forall b. Storable b =&gt; b -&gt; Array b -&gt; IO (Array b)
</span><a href="#local-6989586621679550474"><span class="hs-identifier hs-var hs-var">dupHack</span></a></span></span><span> </span><span id="local-6989586621679550461"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550461"><span class="hs-identifier hs-var">dummy</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550460"><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550460"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-100"></span><span>    </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550459"><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550459"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span id="local-6989586621679550458"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550458"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621679550457"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550457"><span class="hs-identifier hs-var">cap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC b) -&gt; IO (AC b)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550460"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-101"></span><span>    </span><span id="local-6989586621679550456"><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550456"><span class="hs-identifier hs-var">ary</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr b)
forall a. Storable a =&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="GHC.Event.Array.html#allocArray"><span class="hs-identifier hs-var">allocArray</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550457"><span class="hs-identifier hs-var">cap</span></a></span><span>
</span><span id="line-102"></span><span>    </span><span class="annot"><span class="annottext">ForeignPtr b -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550456"><span class="hs-identifier hs-var">ary</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr b -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550455"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550455"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-103"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr b -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550459"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr b -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550454"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550454"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-104"></span><span>        </span><span class="annot"><span class="annottext">Ptr b
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Ptr b -&gt; CSize -&gt; IO (Ptr b)
forall a. Ptr a -&gt; Ptr a -&gt; CSize -&gt; IO (Ptr a)
</span><a href="GHC.Event.Array.html#memcpy"><span class="hs-identifier hs-var">memcpy</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550455"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550454"><span class="hs-identifier hs-var">src</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550458"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">b -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550461"><span class="hs-identifier hs-var">dummy</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-105"></span><span>        </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span>    </span><span class="annot"><span class="annottext">IORef (AC b) -&gt; Array b
forall a. IORef (AC a) -&gt; Array a
</span><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-var">Array</span></a></span><span> </span><span class="annot"><span class="annottext">(IORef (AC b) -&gt; Array b) -&gt; IO (IORef (AC b)) -&gt; IO (Array b)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="GHC.Base.html#fmap"><span class="hs-operator hs-var">`fmap`</span></a></span><span> </span><span class="annot"><span class="annottext">AC b -&gt; IO (IORef (AC b))
forall a. a -&gt; IO (IORef a)
</span><a href="GHC.IORef.html#newIORef"><span class="hs-identifier hs-var">newIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr b -&gt; Int -&gt; Int -&gt; AC b
forall a. ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
</span><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550456"><span class="hs-identifier hs-var">ary</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550458"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550457"><span class="hs-identifier hs-var">cap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-107"></span><span>
</span><span id="line-108"></span><span id="local-6989586621679550656"><span class="annot"><a href="GHC.Event.Array.html#length"><span class="hs-identifier hs-type">length</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550656"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span></span><span>
</span><span id="line-109"></span><span id="length"><span class="annot"><span class="annottext">length :: forall a. Array a -&gt; IO Int
</span><a href="GHC.Event.Array.html#length"><span class="hs-identifier hs-var hs-var">length</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550451"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550451"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-110"></span><span>    </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550450"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550450"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550451"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-111"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550450"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-112"></span><span>
</span><span id="line-113"></span><span id="local-6989586621679550449"><span class="annot"><a href="GHC.Event.Array.html#capacity"><span class="hs-identifier hs-type">capacity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550449"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span></span><span>
</span><span id="line-114"></span><span id="capacity"><span class="annot"><span class="annottext">capacity :: forall a. Array a -&gt; IO Int
</span><a href="GHC.Event.Array.html#capacity"><span class="hs-identifier hs-var hs-var">capacity</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550446"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550446"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-115"></span><span>    </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550445"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550445"><span class="hs-identifier hs-var">cap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550446"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-116"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550445"><span class="hs-identifier hs-var">cap</span></a></span><span>
</span><span id="line-117"></span><span>
</span><span id="line-118"></span><span id="local-6989586621679550653"><span class="annot"><a href="GHC.Event.Array.html#unsafeRead"><span class="hs-identifier hs-type">unsafeRead</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550653"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550653"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550653"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-119"></span><span id="unsafeRead"><span class="annot"><span class="annottext">unsafeRead :: forall a. Storable a =&gt; Array a -&gt; Int -&gt; IO a
</span><a href="GHC.Event.Array.html#unsafeRead"><span class="hs-identifier hs-var hs-var">unsafeRead</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550435"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550435"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550434"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550434"><span class="hs-identifier hs-var">ix</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-120"></span><span>    </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550433"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550433"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550432"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550432"><span class="hs-identifier hs-var">cap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550435"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-121"></span><span>    </span><span class="hs-identifier">CHECK_BOUNDS</span><span class="hs-special">(</span><span class="hs-string">&quot;unsafeRead&quot;</span><span class="hs-special">,</span><span class="hs-identifier">cap</span><span class="hs-special">,</span><span class="hs-identifier">ix</span><span class="hs-special">)</span><span>
</span><span id="line-122"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; (Ptr a -&gt; IO a) -&gt; IO a
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550433"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr a -&gt; IO a) -&gt; IO a) -&gt; (Ptr a -&gt; IO a) -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550428"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550428"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; IO a
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; IO a
</span><a href="Foreign.Storable.html#peekElemOff"><span class="hs-identifier hs-var">peekElemOff</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550428"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550434"><span class="hs-identifier hs-var">ix</span></a></span><span>
</span><span id="line-123"></span><span>        </span><span class="hs-comment">-- this is safe WRT #17760 as we assume that peekElemOff doesn't diverge</span><span>
</span><span id="line-124"></span><span>
</span><span id="line-125"></span><span id="local-6989586621679550647"><span class="annot"><a href="GHC.Event.Array.html#unsafeWrite"><span class="hs-identifier hs-type">unsafeWrite</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550647"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550647"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550647"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-126"></span><span id="unsafeWrite"><span class="annot"><span class="annottext">unsafeWrite :: forall a. Storable a =&gt; Array a -&gt; Int -&gt; a -&gt; IO ()
</span><a href="GHC.Event.Array.html#unsafeWrite"><span class="hs-identifier hs-var hs-var">unsafeWrite</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550423"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550423"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550422"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550422"><span class="hs-identifier hs-var">ix</span></a></span></span><span> </span><span id="local-6989586621679550421"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550421"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-127"></span><span>    </span><span id="local-6989586621679550420"><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550420"><span class="hs-identifier hs-var">ac</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550423"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-128"></span><span>    </span><span class="annot"><span class="annottext">AC a -&gt; Int -&gt; a -&gt; IO ()
forall a. Storable a =&gt; AC a -&gt; Int -&gt; a -&gt; IO ()
</span><a href="GHC.Event.Array.html#unsafeWrite%27"><span class="hs-identifier hs-var">unsafeWrite'</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550420"><span class="hs-identifier hs-var">ac</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550422"><span class="hs-identifier hs-var">ix</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550421"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span id="local-6989586621679550645"><span class="annot"><a href="GHC.Event.Array.html#unsafeWrite%27"><span class="hs-identifier hs-type">unsafeWrite'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550645"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550645"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550645"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-131"></span><span id="unsafeWrite%27"><span class="annot"><span class="annottext">unsafeWrite' :: forall a. Storable a =&gt; AC a -&gt; Int -&gt; a -&gt; IO ()
</span><a href="GHC.Event.Array.html#unsafeWrite%27"><span class="hs-identifier hs-var hs-var">unsafeWrite'</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550411"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550411"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550410"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550410"><span class="hs-identifier hs-var">cap</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550409"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550409"><span class="hs-identifier hs-var">ix</span></a></span></span><span> </span><span id="local-6989586621679550408"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550408"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-132"></span><span>    </span><span class="hs-identifier">CHECK_BOUNDS</span><span class="hs-special">(</span><span class="hs-string">&quot;unsafeWrite'&quot;</span><span class="hs-special">,</span><span class="hs-identifier">cap</span><span class="hs-special">,</span><span class="hs-identifier">ix</span><span class="hs-special">)</span><span>
</span><span id="line-133"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; (Ptr a -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550411"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr a -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr a -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550407"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550407"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; a -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; a -&gt; IO ()
</span><a href="Foreign.Storable.html#pokeElemOff"><span class="hs-identifier hs-var">pokeElemOff</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550407"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550409"><span class="hs-identifier hs-var">ix</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550408"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-134"></span><span>        </span><span class="hs-comment">-- this is safe WRT #17760 as we assume that peekElemOff doesn't diverge</span><span>
</span><span id="line-135"></span><span>
</span><span id="line-136"></span><span class="hs-comment">-- | Precondition: continuation must not diverge due to use of</span><span>
</span><span id="line-137"></span><span class="hs-comment">-- 'unsafeWithForeignPtr'.</span><span>
</span><span id="line-138"></span><span id="local-6989586621679550643"><span class="annot"><a href="GHC.Event.Array.html#unsafeLoad"><span class="hs-identifier hs-type">unsafeLoad</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550643"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550643"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span></span><span>
</span><span id="line-139"></span><span id="unsafeLoad"><span class="annot"><span class="annottext">unsafeLoad :: forall a. Array a -&gt; (Ptr a -&gt; Int -&gt; IO Int) -&gt; IO Int
</span><a href="GHC.Event.Array.html#unsafeLoad"><span class="hs-identifier hs-var hs-var">unsafeLoad</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550401"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550401"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550400"><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; IO Int
</span><a href="#local-6989586621679550400"><span class="hs-identifier hs-var">load</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-140"></span><span>    </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550399"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550399"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550398"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550398"><span class="hs-identifier hs-var">cap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550401"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-141"></span><span>    </span><span id="local-6989586621679550397"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550397"><span class="hs-identifier hs-var">len'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; (Ptr a -&gt; IO Int) -&gt; IO Int
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550399"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr a -&gt; IO Int) -&gt; IO Int) -&gt; (Ptr a -&gt; IO Int) -&gt; IO Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550396"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550396"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; IO Int
</span><a href="#local-6989586621679550400"><span class="hs-identifier hs-var">load</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550396"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550398"><span class="hs-identifier hs-var">cap</span></a></span><span>
</span><span id="line-142"></span><span>    </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; AC a -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550401"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
forall a. ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
</span><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550399"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550397"><span class="hs-identifier hs-var">len'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550398"><span class="hs-identifier hs-var">cap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-143"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550397"><span class="hs-identifier hs-var">len'</span></a></span><span>
</span><span id="line-144"></span><span>
</span><span id="line-145"></span><span class="hs-comment">-- | Reads n elements from the pointer and copies them</span><span>
</span><span id="line-146"></span><span class="hs-comment">-- into the array.</span><span>
</span><span id="line-147"></span><span id="local-6989586621679550640"><span class="annot"><a href="GHC.Event.Array.html#unsafeCopyFromBuffer"><span class="hs-identifier hs-type">unsafeCopyFromBuffer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550640"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550640"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550640"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-148"></span><span id="unsafeCopyFromBuffer"><span class="annot"><span class="annottext">unsafeCopyFromBuffer :: forall a. Storable a =&gt; Array a -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="GHC.Event.Array.html#unsafeCopyFromBuffer"><span class="hs-identifier hs-var hs-var">unsafeCopyFromBuffer</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550384"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550384"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550383"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550383"><span class="hs-identifier hs-var">sptr</span></a></span></span><span> </span><span id="local-6989586621679550382"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550382"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-149"></span><span>    </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550384"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">IO (AC a) -&gt; (AC a -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550381"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550381"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550380"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550380"><span class="hs-identifier hs-var">cap</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-150"></span><span>    </span><span class="hs-identifier">CHECK_BOUNDS</span><span class="hs-special">(</span><span class="hs-string">&quot;unsafeCopyFromBuffer&quot;</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">cap</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">n</span><span class="hs-special">)</span><span>
</span><span id="line-151"></span><span>    </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; (Ptr a -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550381"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr a -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr a -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550379"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550379"><span class="hs-identifier hs-var">pdest</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-152"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550375"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621679550375"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; a -&gt; Int
forall a. Storable a =&gt; Ptr a -&gt; a -&gt; Int
</span><a href="#local-6989586621679550374"><span class="hs-identifier hs-var">sizeOfPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550383"><span class="hs-identifier hs-var">sptr</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-153"></span><span>      </span><span class="annot"><span class="annottext">Ptr a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Ptr a -&gt; CSize -&gt; IO (Ptr a)
forall a. Ptr a -&gt; Ptr a -&gt; CSize -&gt; IO (Ptr a)
</span><a href="GHC.Event.Array.html#memcpy"><span class="hs-identifier hs-var">memcpy</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550379"><span class="hs-identifier hs-var">pdest</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550383"><span class="hs-identifier hs-var">sptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; CSize) -&gt; Int -&gt; CSize
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550382"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550375"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-154"></span><span>      </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; AC a -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550384"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
forall a. ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
</span><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550381"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550382"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550380"><span class="hs-identifier hs-var">cap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-155"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-156"></span><span>    </span><span id="local-6989586621679550636"><span class="annot"><a href="#local-6989586621679550374"><span class="hs-identifier hs-type">sizeOfPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550636"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550636"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550636"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span></span><span>
</span><span id="line-157"></span><span>    </span><span id="local-6989586621679550374"><span class="annot"><span class="annottext">sizeOfPtr :: forall a. Storable a =&gt; Ptr a -&gt; a -&gt; Int
</span><a href="#local-6989586621679550374"><span class="hs-identifier hs-var hs-var">sizeOfPtr</span></a></span></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550371"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550371"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550371"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-158"></span><span>
</span><span id="line-159"></span><span id="local-6989586621679550634"><span class="annot"><a href="GHC.Event.Array.html#ensureCapacity"><span class="hs-identifier hs-type">ensureCapacity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550634"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550634"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-160"></span><span id="ensureCapacity"><span class="annot"><span class="annottext">ensureCapacity :: forall a. Storable a =&gt; Array a -&gt; Int -&gt; IO ()
</span><a href="GHC.Event.Array.html#ensureCapacity"><span class="hs-identifier hs-var hs-var">ensureCapacity</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550363"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550363"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550362"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550362"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-161"></span><span>    </span><span id="local-6989586621679550361"><span class="annot"><span class="annottext">ac :: AC a
</span><a href="#local-6989586621679550361"><span class="hs-identifier hs-var">ac</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550360"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550360"><span class="hs-identifier hs-var">cap</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550363"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-162"></span><span>    </span><span id="local-6989586621679550359"><span class="annot"><span class="annottext">ac' :: AC a
</span><a href="#local-6989586621679550359"><span class="hs-identifier hs-var">ac'</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550358"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550358"><span class="hs-identifier hs-var">cap'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AC a -&gt; Int -&gt; IO (AC a)
forall a. Storable a =&gt; AC a -&gt; Int -&gt; IO (AC a)
</span><a href="GHC.Event.Array.html#ensureCapacity%27"><span class="hs-identifier hs-var">ensureCapacity'</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550361"><span class="hs-identifier hs-var">ac</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550362"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-163"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550358"><span class="hs-identifier hs-var">cap'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550360"><span class="hs-identifier hs-var">cap</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-164"></span><span>      </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; AC a -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550363"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550359"><span class="hs-identifier hs-var">ac'</span></a></span><span>
</span><span id="line-165"></span><span>
</span><span id="line-166"></span><span id="local-6989586621679550632"><span class="annot"><a href="GHC.Event.Array.html#ensureCapacity%27"><span class="hs-identifier hs-type">ensureCapacity'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550632"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550632"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550632"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-167"></span><span id="ensureCapacity%27"><span class="annot"><span class="annottext">ensureCapacity' :: forall a. Storable a =&gt; AC a -&gt; Int -&gt; IO (AC a)
</span><a href="GHC.Event.Array.html#ensureCapacity%27"><span class="hs-identifier hs-var hs-var">ensureCapacity'</span></a></span></span><span> </span><span id="local-6989586621679550350"><span class="annot"><span class="annottext">ac :: AC a
</span><a href="#local-6989586621679550350"><span class="hs-identifier hs-var">ac</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550349"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550349"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span id="local-6989586621679550348"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550348"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621679550347"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550347"><span class="hs-identifier hs-var">cap</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550346"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550346"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-168"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550346"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550347"><span class="hs-identifier hs-var">cap</span></a></span><span>
</span><span id="line-169"></span><span>      </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-170"></span><span>        </span><span id="local-6989586621679550345"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550345"><span class="hs-identifier hs-var">es'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; Int -&gt; Int -&gt; IO (ForeignPtr a)
forall a.
Storable a =&gt;
ForeignPtr a -&gt; Int -&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="GHC.Event.Array.html#reallocArray"><span class="hs-identifier hs-var">reallocArray</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550349"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550344"><span class="hs-identifier hs-var">cap'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550347"><span class="hs-identifier hs-var">cap</span></a></span><span>
</span><span id="line-171"></span><span>        </span><span class="annot"><span class="annottext">AC a -&gt; IO (AC a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
forall a. ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
</span><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550345"><span class="hs-identifier hs-var">es'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550348"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550344"><span class="hs-identifier hs-var">cap'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-172"></span><span>      </span><span class="hs-keyword">else</span><span>
</span><span id="line-173"></span><span>        </span><span class="annot"><span class="annottext">AC a -&gt; IO (AC a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550350"><span class="hs-identifier hs-var">ac</span></a></span><span>
</span><span id="line-174"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-175"></span><span>    </span><span id="local-6989586621679550344"><span class="annot"><span class="annottext">cap' :: Int
</span><a href="#local-6989586621679550344"><span class="hs-identifier hs-var hs-var">cap'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int
</span><a href="GHC.Event.Array.html#firstPowerOf2"><span class="hs-identifier hs-var">firstPowerOf2</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550346"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-176"></span><span>
</span><span id="line-177"></span><span id="local-6989586621679550629"><span id="local-6989586621679550630"><span class="annot"><a href="GHC.Event.Array.html#useAsPtr"><span class="hs-identifier hs-type">useAsPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550630"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550630"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550629"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550629"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-178"></span><span id="useAsPtr"><span class="annot"><span class="annottext">useAsPtr :: forall a b. Array a -&gt; (Ptr a -&gt; Int -&gt; IO b) -&gt; IO b
</span><a href="GHC.Event.Array.html#useAsPtr"><span class="hs-identifier hs-var hs-var">useAsPtr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550342"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550342"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550341"><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; IO b
</span><a href="#local-6989586621679550341"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-179"></span><span>    </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550340"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550340"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span id="local-6989586621679550339"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550339"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550342"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-180"></span><span>    </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550340"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr a -&gt; IO b) -&gt; IO b) -&gt; (Ptr a -&gt; IO b) -&gt; IO b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550338"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550338"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Int -&gt; IO b
</span><a href="#local-6989586621679550341"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679550338"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550339"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-181"></span><span>
</span><span id="line-182"></span><span id="local-6989586621679550626"><span class="annot"><a href="GHC.Event.Array.html#snoc"><span class="hs-identifier hs-type">snoc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550626"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550626"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550626"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-183"></span><span id="snoc"><span class="annot"><span class="annottext">snoc :: forall a. Storable a =&gt; Array a -&gt; a -&gt; IO ()
</span><a href="GHC.Event.Array.html#snoc"><span class="hs-identifier hs-var hs-var">snoc</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550331"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550331"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550330"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550330"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-184"></span><span>    </span><span id="local-6989586621679550329"><span class="annot"><span class="annottext">ac :: AC a
</span><a href="#local-6989586621679550329"><span class="hs-identifier hs-var">ac</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550328"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550328"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550331"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-185"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550325"><span class="annot"><span class="annottext">len' :: Int
</span><a href="#local-6989586621679550325"><span class="hs-identifier hs-var hs-var">len'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550328"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-186"></span><span>    </span><span id="local-6989586621679550323"><span class="annot"><span class="annottext">ac' :: AC a
</span><a href="#local-6989586621679550323"><span class="hs-identifier hs-var">ac'</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550322"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550322"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550321"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550321"><span class="hs-identifier hs-var">cap</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AC a -&gt; Int -&gt; IO (AC a)
forall a. Storable a =&gt; AC a -&gt; Int -&gt; IO (AC a)
</span><a href="GHC.Event.Array.html#ensureCapacity%27"><span class="hs-identifier hs-var">ensureCapacity'</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550329"><span class="hs-identifier hs-var">ac</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550325"><span class="hs-identifier hs-var">len'</span></a></span><span>
</span><span id="line-187"></span><span>    </span><span class="annot"><span class="annottext">AC a -&gt; Int -&gt; a -&gt; IO ()
forall a. Storable a =&gt; AC a -&gt; Int -&gt; a -&gt; IO ()
</span><a href="GHC.Event.Array.html#unsafeWrite%27"><span class="hs-identifier hs-var">unsafeWrite'</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550323"><span class="hs-identifier hs-var">ac'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550328"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679550330"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-188"></span><span>    </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; AC a -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550331"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
forall a. ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
</span><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550322"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550325"><span class="hs-identifier hs-var">len'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550321"><span class="hs-identifier hs-var">cap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-189"></span><span>
</span><span id="line-190"></span><span id="local-6989586621679550624"><span class="annot"><a href="GHC.Event.Array.html#clear"><span class="hs-identifier hs-type">clear</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550624"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-191"></span><span id="clear"><span class="annot"><span class="annottext">clear :: forall a. Array a -&gt; IO ()
</span><a href="GHC.Event.Array.html#clear"><span class="hs-identifier hs-var hs-var">clear</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550320"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550320"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-192"></span><span>  </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; (AC a -&gt; (AC a, ())) -&gt; IO ()
forall a b. IORef a -&gt; (a -&gt; (a, b)) -&gt; IO b
</span><a href="GHC.IORef.html#atomicModifyIORef%27"><span class="hs-identifier hs-var">atomicModifyIORef'</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550320"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">((AC a -&gt; (AC a, ())) -&gt; IO ()) -&gt; (AC a -&gt; (AC a, ())) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550319"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550319"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550318"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550318"><span class="hs-identifier hs-var">cap</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-193"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
forall a. ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
</span><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679550319"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550318"><span class="hs-identifier hs-var">cap</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span id="local-6989586621679550620"><span class="annot"><a href="GHC.Event.Array.html#forM_"><span class="hs-identifier hs-type">forM_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550620"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550620"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550620"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-196"></span><span id="forM_"><span class="annot"><span class="annottext">forM_ :: forall a. Storable a =&gt; Array a -&gt; (a -&gt; IO ()) -&gt; IO ()
</span><a href="GHC.Event.Array.html#forM_"><span class="hs-identifier hs-var hs-var">forM_</span></a></span></span><span> </span><span id="local-6989586621679550313"><span class="annot"><span class="annottext">Array a
</span><a href="#local-6989586621679550313"><span class="hs-identifier hs-var">ary</span></a></span></span><span> </span><span id="local-6989586621679550312"><span class="annot"><span class="annottext">a -&gt; IO ()
</span><a href="#local-6989586621679550312"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Array a -&gt; (a -&gt; IO ()) -&gt; a -&gt; IO ()
forall b. Storable b =&gt; Array b -&gt; (b -&gt; IO ()) -&gt; b -&gt; IO ()
</span><a href="#local-6989586621679550311"><span class="hs-identifier hs-var">forHack</span></a></span><span> </span><span class="annot"><span class="annottext">Array a
</span><a href="#local-6989586621679550313"><span class="hs-identifier hs-var">ary</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; IO ()
</span><a href="#local-6989586621679550312"><span class="hs-identifier hs-var">g</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-197"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-198"></span><span>    </span><span id="local-6989586621679550618"><span class="annot"><a href="#local-6989586621679550311"><span class="hs-identifier hs-type">forHack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550618"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550618"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550618"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550618"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-199"></span><span>    </span><span id="local-6989586621679550311"><span class="annot"><span class="annottext">forHack :: forall b. Storable b =&gt; Array b -&gt; (b -&gt; IO ()) -&gt; b -&gt; IO ()
</span><a href="#local-6989586621679550311"><span class="hs-identifier hs-var hs-var">forHack</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550308"><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550308"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550307"><span class="annot"><span class="annottext">b -&gt; IO ()
</span><a href="#local-6989586621679550307"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679550306"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550306"><span class="hs-identifier hs-var">dummy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-200"></span><span>      </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550305"><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550305"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span id="local-6989586621679550304"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550304"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC b) -&gt; IO (AC b)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550308"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-201"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550302"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621679550302"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550306"><span class="hs-identifier hs-var">dummy</span></a></span><span>
</span><span id="line-202"></span><span>          </span><span id="local-6989586621679550300"><span class="annot"><span class="annottext">offset :: Int
</span><a href="#local-6989586621679550300"><span class="hs-identifier hs-var hs-var">offset</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550304"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550302"><span class="hs-identifier hs-var">size</span></a></span><span>
</span><span id="line-203"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr b -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550305"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr b -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550299"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550299"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-204"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550292"><span class="annot"><span class="annottext">go :: Int -&gt; IO ()
</span><a href="#local-6989586621679550292"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679550291"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550291"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550291"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550300"><span class="hs-identifier hs-var">offset</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-205"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-206"></span><span>              </span><span class="annot"><span class="annottext">b -&gt; IO ()
</span><a href="#local-6989586621679550307"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; IO ()) -&gt; IO b -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; IO b
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550299"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Int -&gt; Ptr b
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550291"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-207"></span><span>              </span><span class="annot"><span class="annottext">Int -&gt; IO ()
</span><a href="#local-6989586621679550292"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550291"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550302"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-208"></span><span>        </span><span class="annot"><span class="annottext">Int -&gt; IO ()
</span><a href="#local-6989586621679550292"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-209"></span><span>
</span><span id="line-210"></span><span id="local-6989586621679550610"><span id="local-6989586621679550611"><span class="annot"><a href="GHC.Event.Array.html#loop"><span class="hs-identifier hs-type">loop</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550611"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550611"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550610"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550610"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550611"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550610"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span></span><span>
</span><span id="line-211"></span><span id="loop"><span class="annot"><span class="annottext">loop :: forall a b.
Storable a =&gt;
Array a -&gt; b -&gt; (b -&gt; a -&gt; IO (b, Bool)) -&gt; IO ()
</span><a href="GHC.Event.Array.html#loop"><span class="hs-identifier hs-var hs-var">loop</span></a></span></span><span> </span><span id="local-6989586621679550284"><span class="annot"><span class="annottext">Array a
</span><a href="#local-6989586621679550284"><span class="hs-identifier hs-var">ary</span></a></span></span><span> </span><span id="local-6989586621679550283"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550283"><span class="hs-identifier hs-var">z</span></a></span></span><span> </span><span id="local-6989586621679550282"><span class="annot"><span class="annottext">b -&gt; a -&gt; IO (b, Bool)
</span><a href="#local-6989586621679550282"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Array a -&gt; b -&gt; (b -&gt; a -&gt; IO (b, Bool)) -&gt; a -&gt; IO ()
forall b c.
Storable b =&gt;
Array b -&gt; c -&gt; (c -&gt; b -&gt; IO (c, Bool)) -&gt; b -&gt; IO ()
</span><a href="#local-6989586621679550281"><span class="hs-identifier hs-var">loopHack</span></a></span><span> </span><span class="annot"><span class="annottext">Array a
</span><a href="#local-6989586621679550284"><span class="hs-identifier hs-var">ary</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550283"><span class="hs-identifier hs-var">z</span></a></span><span> </span><span class="annot"><span class="annottext">b -&gt; a -&gt; IO (b, Bool)
</span><a href="#local-6989586621679550282"><span class="hs-identifier hs-var">g</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-212"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-213"></span><span>    </span><span id="local-6989586621679550606"><span id="local-6989586621679550607"><span class="annot"><a href="#local-6989586621679550281"><span class="hs-identifier hs-type">loopHack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550607"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550607"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550606"><span class="hs-identifier hs-type">c</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550606"><span class="hs-identifier hs-type">c</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550607"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550606"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550607"><span class="hs-identifier hs-type">b</span></a></span><span>
</span><span id="line-214"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span></span><span>
</span><span id="line-215"></span><span>    </span><span id="local-6989586621679550281"><span class="annot"><span class="annottext">loopHack :: forall b c.
Storable b =&gt;
Array b -&gt; c -&gt; (c -&gt; b -&gt; IO (c, Bool)) -&gt; b -&gt; IO ()
</span><a href="#local-6989586621679550281"><span class="hs-identifier hs-var hs-var">loopHack</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550278"><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550278"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550277"><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621679550277"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span id="local-6989586621679550276"><span class="annot"><span class="annottext">c -&gt; b -&gt; IO (c, Bool)
</span><a href="#local-6989586621679550276"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679550275"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550275"><span class="hs-identifier hs-var">dummy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-216"></span><span>      </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550274"><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550274"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span id="local-6989586621679550273"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550273"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC b) -&gt; IO (AC b)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550278"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-217"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550271"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621679550271"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550275"><span class="hs-identifier hs-var">dummy</span></a></span><span>
</span><span id="line-218"></span><span>          </span><span id="local-6989586621679550269"><span class="annot"><span class="annottext">offset :: Int
</span><a href="#local-6989586621679550269"><span class="hs-identifier hs-var hs-var">offset</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550273"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550271"><span class="hs-identifier hs-var">size</span></a></span><span>
</span><span id="line-219"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr b -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550274"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr b -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550268"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550268"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-220"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550260"><span class="annot"><span class="annottext">go :: Int -&gt; c -&gt; IO ()
</span><a href="#local-6989586621679550260"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679550259"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550259"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621679550258"><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621679550258"><span class="hs-identifier hs-var">k</span></a></span></span><span>
</span><span id="line-221"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550259"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550269"><span class="hs-identifier hs-var">offset</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-222"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-223"></span><span>                      </span><span class="hs-special">(</span><span id="local-6989586621679550257"><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621679550257"><span class="hs-identifier hs-var">k'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679550256"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679550256"><span class="hs-identifier hs-var">cont</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">c -&gt; b -&gt; IO (c, Bool)
</span><a href="#local-6989586621679550276"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621679550258"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; IO (c, Bool)) -&gt; IO b -&gt; IO (c, Bool)
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; IO b
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550268"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Int -&gt; Ptr b
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550259"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-224"></span><span>                      </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679550256"><span class="hs-identifier hs-var">cont</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; c -&gt; IO ()
</span><a href="#local-6989586621679550260"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550259"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550271"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621679550257"><span class="hs-identifier hs-var">k'</span></a></span><span>
</span><span id="line-225"></span><span>        </span><span class="annot"><span class="annottext">Int -&gt; c -&gt; IO ()
</span><a href="#local-6989586621679550260"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621679550277"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-226"></span><span>
</span><span id="line-227"></span><span id="local-6989586621679550603"><span class="annot"><a href="GHC.Event.Array.html#findIndex"><span class="hs-identifier hs-type">findIndex</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550603"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550603"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550603"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679550603"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span><span>
</span><span id="line-228"></span><span id="findIndex"><span class="annot"><span class="annottext">findIndex :: forall a.
Storable a =&gt;
(a -&gt; Bool) -&gt; Array a -&gt; IO (Maybe (Int, a))
</span><a href="GHC.Event.Array.html#findIndex"><span class="hs-identifier hs-var hs-var">findIndex</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; (a -&gt; Bool) -&gt; Array a -&gt; IO (Maybe (Int, a))
forall b.
Storable b =&gt;
b -&gt; (b -&gt; Bool) -&gt; Array b -&gt; IO (Maybe (Int, b))
</span><a href="#local-6989586621679550251"><span class="hs-identifier hs-var">findHack</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-229"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-230"></span><span>  </span><span id="local-6989586621679550601"><span class="annot"><a href="#local-6989586621679550251"><span class="hs-identifier hs-type">findHack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550601"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550601"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679550601"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550601"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679550601"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span><span>
</span><span id="line-231"></span><span>  </span><span id="local-6989586621679550251"><span class="annot"><span class="annottext">findHack :: forall b.
Storable b =&gt;
b -&gt; (b -&gt; Bool) -&gt; Array b -&gt; IO (Maybe (Int, b))
</span><a href="#local-6989586621679550251"><span class="hs-identifier hs-var hs-var">findHack</span></a></span></span><span> </span><span id="local-6989586621679550246"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550246"><span class="hs-identifier hs-var">dummy</span></a></span></span><span> </span><span id="local-6989586621679550245"><span class="annot"><span class="annottext">b -&gt; Bool
</span><a href="#local-6989586621679550245"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550244"><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550244"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-232"></span><span>    </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550243"><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550243"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span id="local-6989586621679550242"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550242"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC b) -&gt; IO (AC b)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550244"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-233"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550240"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621679550240"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550246"><span class="hs-identifier hs-var">dummy</span></a></span><span>
</span><span id="line-234"></span><span>        </span><span id="local-6989586621679550238"><span class="annot"><span class="annottext">offset :: Int
</span><a href="#local-6989586621679550238"><span class="hs-identifier hs-var hs-var">offset</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550242"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550240"><span class="hs-identifier hs-var">size</span></a></span><span>
</span><span id="line-235"></span><span>    </span><span class="annot"><span class="annottext">ForeignPtr b
-&gt; (Ptr b -&gt; IO (Maybe (Int, b))) -&gt; IO (Maybe (Int, b))
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550243"><span class="hs-identifier hs-var">es</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr b -&gt; IO (Maybe (Int, b))) -&gt; IO (Maybe (Int, b)))
-&gt; (Ptr b -&gt; IO (Maybe (Int, b))) -&gt; IO (Maybe (Int, b))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550237"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550237"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-236"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550227"><span class="annot"><span class="annottext">go :: Int -&gt; t -&gt; IO (Maybe (t, b))
</span><a href="#local-6989586621679550227"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679550226"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550226"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679550225"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679550225"><span class="hs-identifier hs-var">i</span></a></span></span><span>
</span><span id="line-237"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550226"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550238"><span class="hs-identifier hs-var">offset</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (t, b) -&gt; IO (Maybe (t, b))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (t, b)
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-238"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-239"></span><span>                </span><span id="local-6989586621679550224"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550224"><span class="hs-identifier hs-var">val</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; IO b
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550237"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Int -&gt; Ptr b
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550226"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-240"></span><span>                </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">b -&gt; Bool
</span><a href="#local-6989586621679550245"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550224"><span class="hs-identifier hs-var">val</span></a></span><span>
</span><span id="line-241"></span><span>                  </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe (t, b) -&gt; IO (Maybe (t, b))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe (t, b) -&gt; IO (Maybe (t, b)))
-&gt; Maybe (t, b) -&gt; IO (Maybe (t, b))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(t, b) -&gt; Maybe (t, b)
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679550225"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550224"><span class="hs-identifier hs-var">val</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-242"></span><span>                  </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Int -&gt; t -&gt; IO (Maybe (t, b))
</span><a href="#local-6989586621679550227"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550226"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550240"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679550225"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">t -&gt; t -&gt; t
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-243"></span><span>      </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; IO (Maybe (Int, b))
forall {t}. Num t =&gt; Int -&gt; t -&gt; IO (Maybe (t, b))
</span><a href="#local-6989586621679550227"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-244"></span><span>
</span><span id="line-245"></span><span id="local-6989586621679550597"><span class="annot"><a href="GHC.Event.Array.html#concat"><span class="hs-identifier hs-type">concat</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550597"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550597"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550597"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-246"></span><span id="concat"><span class="annot"><span class="annottext">concat :: forall a. Storable a =&gt; Array a -&gt; Array a -&gt; IO ()
</span><a href="GHC.Event.Array.html#concat"><span class="hs-identifier hs-var hs-var">concat</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550218"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550218"><span class="hs-identifier hs-var">d</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550217"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550217"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-247"></span><span>  </span><span id="local-6989586621679550216"><span class="annot"><span class="annottext">da :: AC a
</span><a href="#local-6989586621679550216"><span class="hs-identifier hs-var">da</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550215"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550215"><span class="hs-identifier hs-var">dlen</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550218"><span class="hs-identifier hs-var">d</span></a></span><span>
</span><span id="line-248"></span><span>  </span><span id="local-6989586621679550214"><span class="annot"><span class="annottext">sa :: AC a
</span><a href="#local-6989586621679550214"><span class="hs-identifier hs-var">sa</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550213"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550213"><span class="hs-identifier hs-var">slen</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550217"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-249"></span><span>  </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; AC a -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550218"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">(AC a -&gt; IO ()) -&gt; IO (AC a) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">AC a -&gt; Int -&gt; AC a -&gt; Int -&gt; Int -&gt; IO (AC a)
forall a.
Storable a =&gt;
AC a -&gt; Int -&gt; AC a -&gt; Int -&gt; Int -&gt; IO (AC a)
</span><a href="GHC.Event.Array.html#copy%27"><span class="hs-identifier hs-var">copy'</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550216"><span class="hs-identifier hs-var">da</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550215"><span class="hs-identifier hs-var">dlen</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550214"><span class="hs-identifier hs-var">sa</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550213"><span class="hs-identifier hs-var">slen</span></a></span><span>
</span><span id="line-250"></span><span>
</span><span id="line-251"></span><span class="hs-comment">-- | Copy part of the source array into the destination array. The</span><span>
</span><span id="line-252"></span><span class="hs-comment">-- destination array is resized if not large enough.</span><span>
</span><span id="line-253"></span><span id="local-6989586621679550594"><span class="annot"><a href="GHC.Event.Array.html#copy"><span class="hs-identifier hs-type">copy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550594"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550594"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550594"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-254"></span><span id="copy"><span class="annot"><span class="annottext">copy :: forall a.
Storable a =&gt;
Array a -&gt; Int -&gt; Array a -&gt; Int -&gt; Int -&gt; IO ()
</span><a href="GHC.Event.Array.html#copy"><span class="hs-identifier hs-var hs-var">copy</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550206"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550206"><span class="hs-identifier hs-var">d</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550205"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550205"><span class="hs-identifier hs-var">dstart</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550204"><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550204"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550203"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550203"><span class="hs-identifier hs-var">sstart</span></a></span></span><span> </span><span id="local-6989586621679550202"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550202"><span class="hs-identifier hs-var">maxCount</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-255"></span><span>  </span><span id="local-6989586621679550201"><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550201"><span class="hs-identifier hs-var">da</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550206"><span class="hs-identifier hs-var">d</span></a></span><span>
</span><span id="line-256"></span><span>  </span><span id="local-6989586621679550200"><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550200"><span class="hs-identifier hs-var">sa</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; IO (AC a)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550204"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-257"></span><span>  </span><span class="annot"><span class="annottext">IORef (AC a) -&gt; AC a -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC a)
</span><a href="#local-6989586621679550206"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">(AC a -&gt; IO ()) -&gt; IO (AC a) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">AC a -&gt; Int -&gt; AC a -&gt; Int -&gt; Int -&gt; IO (AC a)
forall a.
Storable a =&gt;
AC a -&gt; Int -&gt; AC a -&gt; Int -&gt; Int -&gt; IO (AC a)
</span><a href="GHC.Event.Array.html#copy%27"><span class="hs-identifier hs-var">copy'</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550201"><span class="hs-identifier hs-var">da</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550205"><span class="hs-identifier hs-var">dstart</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550200"><span class="hs-identifier hs-var">sa</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550203"><span class="hs-identifier hs-var">sstart</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550202"><span class="hs-identifier hs-var">maxCount</span></a></span><span>
</span><span id="line-258"></span><span>
</span><span id="line-259"></span><span class="hs-comment">-- | Copy part of the source array into the destination array. The</span><span>
</span><span id="line-260"></span><span class="hs-comment">-- destination array is resized if not large enough.</span><span>
</span><span id="line-261"></span><span id="local-6989586621679550595"><span class="annot"><a href="GHC.Event.Array.html#copy%27"><span class="hs-identifier hs-type">copy'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550595"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550595"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550595"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550595"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-262"></span><span id="copy%27"><span class="annot"><span class="annottext">copy' :: forall a.
Storable a =&gt;
AC a -&gt; Int -&gt; AC a -&gt; Int -&gt; Int -&gt; IO (AC a)
</span><a href="GHC.Event.Array.html#copy%27"><span class="hs-identifier hs-var hs-var">copy'</span></a></span></span><span> </span><span id="local-6989586621679550195"><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550195"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span id="local-6989586621679550194"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550194"><span class="hs-identifier hs-var">dstart</span></a></span></span><span> </span><span id="local-6989586621679550193"><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550193"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span id="local-6989586621679550192"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550192"><span class="hs-identifier hs-var">sstart</span></a></span></span><span> </span><span id="local-6989586621679550191"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550191"><span class="hs-identifier hs-var">maxCount</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AC a -&gt; AC a -&gt; a -&gt; IO (AC a)
forall b. Storable b =&gt; AC b -&gt; AC b -&gt; b -&gt; IO (AC b)
</span><a href="#local-6989586621679550190"><span class="hs-identifier hs-var">copyHack</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550195"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">AC a
</span><a href="#local-6989586621679550193"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-263"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-264"></span><span>  </span><span id="local-6989586621679550591"><span class="annot"><a href="#local-6989586621679550190"><span class="hs-identifier hs-type">copyHack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550591"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550591"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550591"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550591"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550591"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-265"></span><span>  </span><span id="local-6989586621679550190"><span class="annot"><span class="annottext">copyHack :: forall b. Storable b =&gt; AC b -&gt; AC b -&gt; b -&gt; IO (AC b)
</span><a href="#local-6989586621679550190"><span class="hs-identifier hs-var hs-var">copyHack</span></a></span></span><span> </span><span id="local-6989586621679550163"><span class="annot"><span class="annottext">dac :: AC b
</span><a href="#local-6989586621679550163"><span class="hs-identifier hs-var">dac</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679550162"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550162"><span class="hs-identifier hs-var">oldLen</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550161"><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550161"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span id="local-6989586621679550160"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550160"><span class="hs-identifier hs-var">slen</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550159"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550159"><span class="hs-identifier hs-var">dummy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-266"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550191"><span class="hs-identifier hs-var">maxCount</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550194"><span class="hs-identifier hs-var">dstart</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550194"><span class="hs-identifier hs-var">dstart</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550162"><span class="hs-identifier hs-var">oldLen</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550192"><span class="hs-identifier hs-var">sstart</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span>
</span><span id="line-267"></span><span>          </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550192"><span class="hs-identifier hs-var">sstart</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550160"><span class="hs-identifier hs-var">slen</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; IO ()
forall a. [Char] -&gt; a
</span><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier hs-var">errorWithoutStackTrace</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;copy: bad offsets or lengths&quot;</span></span><span>
</span><span id="line-268"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550157"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621679550157"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550159"><span class="hs-identifier hs-var">dummy</span></a></span><span>
</span><span id="line-269"></span><span>        </span><span id="local-6989586621679550154"><span class="annot"><span class="annottext">count :: Int
</span><a href="#local-6989586621679550154"><span class="hs-identifier hs-var hs-var">count</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><a href="../../ghc-prim/src/GHC.Classes.html#min"><span class="hs-identifier hs-var">min</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550191"><span class="hs-identifier hs-var">maxCount</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550160"><span class="hs-identifier hs-var">slen</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550192"><span class="hs-identifier hs-var">sstart</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-270"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550154"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-271"></span><span>      </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">AC b -&gt; IO (AC b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">AC b
</span><a href="#local-6989586621679550163"><span class="hs-identifier hs-var">dac</span></a></span><span>
</span><span id="line-272"></span><span>      </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-273"></span><span>        </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550152"><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550152"><span class="hs-identifier hs-var">dst</span></a></span></span><span> </span><span id="local-6989586621679550151"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550151"><span class="hs-identifier hs-var">dlen</span></a></span></span><span> </span><span id="local-6989586621679550150"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550150"><span class="hs-identifier hs-var">dcap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AC b -&gt; Int -&gt; IO (AC b)
forall a. Storable a =&gt; AC a -&gt; Int -&gt; IO (AC a)
</span><a href="GHC.Event.Array.html#ensureCapacity%27"><span class="hs-identifier hs-var">ensureCapacity'</span></a></span><span> </span><span class="annot"><span class="annottext">AC b
</span><a href="#local-6989586621679550163"><span class="hs-identifier hs-var">dac</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550194"><span class="hs-identifier hs-var">dstart</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550154"><span class="hs-identifier hs-var">count</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-274"></span><span>        </span><span class="annot"><span class="annottext">ForeignPtr b -&gt; (Ptr b -&gt; IO (AC b)) -&gt; IO (AC b)
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550152"><span class="hs-identifier hs-var">dst</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr b -&gt; IO (AC b)) -&gt; IO (AC b))
-&gt; (Ptr b -&gt; IO (AC b)) -&gt; IO (AC b)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550149"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550149"><span class="hs-identifier hs-var">dptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-275"></span><span>          </span><span class="annot"><span class="annottext">ForeignPtr b -&gt; (Ptr b -&gt; IO (AC b)) -&gt; IO (AC b)
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550161"><span class="hs-identifier hs-var">src</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr b -&gt; IO (AC b)) -&gt; IO (AC b))
-&gt; (Ptr b -&gt; IO (AC b)) -&gt; IO (AC b)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550148"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550148"><span class="hs-identifier hs-var">sptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-276"></span><span>            </span><span class="annot"><span class="annottext">Ptr Any
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Any -&gt; Ptr Any -&gt; CSize -&gt; IO (Ptr Any)
forall a. Ptr a -&gt; Ptr a -&gt; CSize -&gt; IO (Ptr a)
</span><a href="GHC.Event.Array.html#memcpy"><span class="hs-identifier hs-var">memcpy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550149"><span class="hs-identifier hs-var">dptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Int -&gt; Ptr Any
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550194"><span class="hs-identifier hs-var">dstart</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550157"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-277"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550148"><span class="hs-identifier hs-var">sptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Int -&gt; Ptr Any
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550192"><span class="hs-identifier hs-var">sstart</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550157"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-278"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550154"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550157"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-279"></span><span>            </span><span class="annot"><span class="annottext">AC b -&gt; IO (AC b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(AC b -&gt; IO (AC b)) -&gt; AC b -&gt; IO (AC b)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b -&gt; Int -&gt; Int -&gt; AC b
forall a. ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
</span><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550152"><span class="hs-identifier hs-var">dst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><a href="../../ghc-prim/src/GHC.Classes.html#max"><span class="hs-identifier hs-var">max</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550151"><span class="hs-identifier hs-var">dlen</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550194"><span class="hs-identifier hs-var">dstart</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550154"><span class="hs-identifier hs-var">count</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550150"><span class="hs-identifier hs-var">dcap</span></a></span><span>
</span><span id="line-280"></span><span>
</span><span id="line-281"></span><span id="local-6989586621679550146"><span class="annot"><a href="GHC.Event.Array.html#removeAt"><span class="hs-identifier hs-type">removeAt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550146"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550146"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-282"></span><span id="removeAt"><span class="annot"><span class="annottext">removeAt :: forall a. Storable a =&gt; Array a -&gt; Int -&gt; IO ()
</span><a href="GHC.Event.Array.html#removeAt"><span class="hs-identifier hs-var hs-var">removeAt</span></a></span></span><span> </span><span id="local-6989586621679550141"><span class="annot"><span class="annottext">Array a
</span><a href="#local-6989586621679550141"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621679550140"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550140"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Array a -&gt; a -&gt; IO ()
forall a. Storable a =&gt; Array a -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679550139"><span class="hs-identifier hs-var">removeHack</span></a></span><span> </span><span class="annot"><span class="annottext">Array a
</span><a href="#local-6989586621679550141"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-283"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-284"></span><span>  </span><span id="local-6989586621679550138"><span class="annot"><a href="#local-6989586621679550139"><span class="hs-identifier hs-type">removeHack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550138"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550138"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679550138"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-285"></span><span>  </span><span id="local-6989586621679550139"><span class="annot"><span class="annottext">removeHack :: forall a. Storable a =&gt; Array a -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679550139"><span class="hs-identifier hs-var hs-var">removeHack</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Event.Array.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span id="local-6989586621679550115"><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550115"><span class="hs-identifier hs-var">ary</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679550114"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550114"><span class="hs-identifier hs-var">dummy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-286"></span><span>    </span><span class="annot"><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-type">AC</span></a></span><span> </span><span id="local-6989586621679550113"><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550113"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span id="local-6989586621679550112"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550112"><span class="hs-identifier hs-var">oldLen</span></a></span></span><span> </span><span id="local-6989586621679550111"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550111"><span class="hs-identifier hs-var">cap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (AC b) -&gt; IO (AC b)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550115"><span class="hs-identifier hs-var">ary</span></a></span><span>
</span><span id="line-287"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550140"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550140"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550112"><span class="hs-identifier hs-var">oldLen</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; IO ()
forall a. [Char] -&gt; a
</span><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier hs-var">errorWithoutStackTrace</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;removeAt: invalid index&quot;</span></span><span>
</span><span id="line-288"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679550109"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621679550109"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679550114"><span class="hs-identifier hs-var">dummy</span></a></span><span>
</span><span id="line-289"></span><span>        </span><span id="local-6989586621679550106"><span class="annot"><span class="annottext">newLen :: Int
</span><a href="#local-6989586621679550106"><span class="hs-identifier hs-var hs-var">newLen</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550112"><span class="hs-identifier hs-var">oldLen</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-290"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550106"><span class="hs-identifier hs-var">newLen</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550140"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550106"><span class="hs-identifier hs-var">newLen</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ())
-&gt; ((Ptr b -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-291"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr b -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550113"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr b -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr b -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679550105"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550105"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-292"></span><span>        </span><span class="annot"><span class="annottext">Ptr Any
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Any -&gt; Ptr Any -&gt; CSize -&gt; IO (Ptr Any)
forall a. Ptr a -&gt; Ptr a -&gt; CSize -&gt; IO (Ptr a)
</span><a href="GHC.Event.Array.html#memmove"><span class="hs-identifier hs-var">memmove</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550105"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Int -&gt; Ptr Any
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550109"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550140"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-293"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679550105"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Int -&gt; Ptr Any
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550109"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550140"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550109"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550106"><span class="hs-identifier hs-var">newLen</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550140"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-295"></span><span>        </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-296"></span><span>    </span><span class="annot"><span class="annottext">IORef (AC b) -&gt; AC b -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (AC b)
</span><a href="#local-6989586621679550115"><span class="hs-identifier hs-var">ary</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr b -&gt; Int -&gt; Int -&gt; AC b
forall a. ForeignPtr a -&gt; Int -&gt; Int -&gt; AC a
</span><a href="GHC.Event.Array.html#AC"><span class="hs-identifier hs-var">AC</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr b
</span><a href="#local-6989586621679550113"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550106"><span class="hs-identifier hs-var">newLen</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550111"><span class="hs-identifier hs-var">cap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-297"></span><span>
</span><span id="line-298"></span><span class="hs-comment">{-The firstPowerOf2 function works by setting all bits on the right-hand
side of the most significant flagged bit to 1, and then incrementing
the entire value at the end so it &quot;rolls over&quot; to the nearest power of
two.
-}</span><span>
</span><span id="line-303"></span><span>
</span><span id="line-304"></span><span class="hs-comment">-- | Computes the next-highest power of two for a particular integer,</span><span>
</span><span id="line-305"></span><span class="hs-comment">-- @n@.  If @n@ is already a power of two, returns @n@.  If @n@ is</span><span>
</span><span id="line-306"></span><span class="hs-comment">-- zero, returns zero, even though zero is not a power of two.</span><span>
</span><span id="line-307"></span><span class="annot"><a href="GHC.Event.Array.html#firstPowerOf2"><span class="hs-identifier hs-type">firstPowerOf2</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-308"></span><span id="firstPowerOf2"><span class="annot"><span class="annottext">firstPowerOf2 :: Int -&gt; Int
</span><a href="GHC.Event.Array.html#firstPowerOf2"><span class="hs-identifier hs-var hs-var">firstPowerOf2</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679550103"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550103"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-309"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679550100"><span class="annot"><span class="annottext">n1 :: Int
</span><a href="#local-6989586621679550100"><span class="hs-identifier hs-var hs-var">n1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550103"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-310"></span><span>        </span><span class="hs-glyph">!</span><span id="local-6989586621679550096"><span class="annot"><span class="annottext">n2 :: Int
</span><a href="#local-6989586621679550096"><span class="hs-identifier hs-var hs-var">n2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550100"><span class="hs-identifier hs-var">n1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550100"><span class="hs-identifier hs-var">n1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Bits.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-311"></span><span>        </span><span class="hs-glyph">!</span><span id="local-6989586621679550093"><span class="annot"><span class="annottext">n3 :: Int
</span><a href="#local-6989586621679550093"><span class="hs-identifier hs-var hs-var">n3</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550096"><span class="hs-identifier hs-var">n2</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550096"><span class="hs-identifier hs-var">n2</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Bits.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span>
</span><span id="line-312"></span><span>        </span><span class="hs-glyph">!</span><span id="local-6989586621679550090"><span class="annot"><span class="annottext">n4 :: Int
</span><a href="#local-6989586621679550090"><span class="hs-identifier hs-var hs-var">n4</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550093"><span class="hs-identifier hs-var">n3</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550093"><span class="hs-identifier hs-var">n3</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Bits.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span class="hs-special">)</span><span>
</span><span id="line-313"></span><span>        </span><span class="hs-glyph">!</span><span id="local-6989586621679550087"><span class="annot"><span class="annottext">n5 :: Int
</span><a href="#local-6989586621679550087"><span class="hs-identifier hs-var hs-var">n5</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550090"><span class="hs-identifier hs-var">n4</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550090"><span class="hs-identifier hs-var">n4</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Bits.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">8</span></span><span class="hs-special">)</span><span>
</span><span id="line-314"></span><span>        </span><span class="hs-glyph">!</span><span id="local-6989586621679550084"><span class="annot"><span class="annottext">n6 :: Int
</span><a href="#local-6989586621679550084"><span class="hs-identifier hs-var hs-var">n6</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550087"><span class="hs-identifier hs-var">n5</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550087"><span class="hs-identifier hs-var">n5</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Bits.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">16</span></span><span class="hs-special">)</span><span class="hs-cpp">
#if WORD_SIZE_IN_BITS == 32
</span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-identifier">n6</span><span> </span><span class="hs-operator">+</span><span> </span><span class="hs-number">1</span><span class="hs-cpp">
#elif WORD_SIZE_IN_BITS == 64
</span><span>        </span><span class="hs-glyph">!</span><span id="local-6989586621679550081"><span class="annot"><span class="annottext">n7 :: Int
</span><a href="#local-6989586621679550081"><span class="hs-identifier hs-var hs-var">n7</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550084"><span class="hs-identifier hs-var">n6</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550084"><span class="hs-identifier hs-var">n6</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Bits.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">32</span></span><span class="hs-special">)</span><span>
</span><span id="line-319"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679550081"><span class="hs-identifier hs-var">n7</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-cpp">
#else
</span><span class="hs-cpp"># error firstPowerOf2 not defined on this architecture
</span><span class="hs-cpp">#endif
</span><span>
</span><span id="line-324"></span><span id="local-6989586621679550668"><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;string.h memcpy&quot;</span></span><span>
</span><span id="line-325"></span><span>    </span><span id="memcpy"><span class="annot"><a href="GHC.Event.Array.html#memcpy"><span class="hs-identifier hs-var">memcpy</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550668"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550668"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550668"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-326"></span><span>
</span><span id="line-327"></span><span id="local-6989586621679550080"><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;string.h memmove&quot;</span></span><span>
</span><span id="line-328"></span><span>    </span><span id="memmove"><span class="annot"><a href="GHC.Event.Array.html#memmove"><span class="hs-identifier hs-var">memmove</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550080"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550080"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679550080"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-329"></span><span>
</span><span id="line-330"></span></pre></body></html>